<!DOCTYPE html>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script>
test(function() {
    var p = document.createElement('p');
    document.replaceChild(p, document.documentElement);
    p.innerHTML = '<form>\n<p>\n<ruby>\n<rb>\n</rb></ruby></p><table>\n</table></form>\n<ruby>\n<p>\n</p><table></table></ruby>';
    var s = document.querySelector('rb').firstChild;
    var e = document.querySelector('table');
    var ol = document.createElement('ol');
    ol.innerHTML = '\n<li>\n\n</li>\n';
    e.insertBefore(ol, e.firstChild);
    var r = document.createRange();
    r.setStart(s, 0);
    r.setEnd(e, 1);
    window.getSelection().removeAllRanges();
    window.getSelection().addRange(r);
    document.designMode = 'on';
    document.execCommand('InsertParagraph');
}, 'InsertParagraph command should not crash with editable P root element.');
</script>
